<template>
  <div class="transferSettle">
    <ul class="query">
      <li class="query-option">
        <span>关键词：</span>
        <el-input size="medium" v-model="queryData.date" placeholder="转让单号、用户ID、商品名称"></el-input>
      </li>
      <li class="query-option">
        <span>转让时间：</span>
        <el-date-picker type="daterange" v-model="queryData.date" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" size="medium">
        </el-date-picker>
      </li>
      <li class="query-option">
        <span>酒的结算：</span>
        <el-select size="medium" v-model="queryData.date">
          <el-option value="0">全部</el-option>
          <el-option value="1">待充值结算</el-option>
          <el-option value="2">已结算</el-option>
        </el-select>
      </li>
       <li class="query-option">
        <span>仓储费结算：</span>
        <el-select size="medium" v-model="queryData.date">
          <el-option value="0">全部</el-option>
          <el-option value="1">未结算</el-option>
          <el-option value="2">已结算</el-option>
        </el-select>
      </li>
      <li class="query-option">
        <el-button size="medium" type="primary" @click="getTableData">查询</el-button>
        <el-button size="medium" type="warning" @click="exportData">导出</el-button>
      </li>
    </ul>
    <div class="wrapper">
      <el-table class="table" :data="tableData" stripe highlight-current-row border>
        <el-table-column align="center" type="index" label="序号" width="50">
        </el-table-column>
        <el-table-column align="center" prop="" label="用户ID">
        </el-table-column>
        <el-table-column align="center" prop="" label="转让单号">
        </el-table-column>
        <el-table-column align="center" prop="" label="转让数量/单位">
        </el-table-column>
        <el-table-column align="center" prop="" label="商品名称">
        </el-table-column>
        <el-table-column align="center" prop="" label="申请转让时间">
        </el-table-column>
        <el-table-column align="center" prop="" label="截止转让时间">
        </el-table-column>
        <el-table-column align="center" prop="" label="酒的实际金额总计（元）">
        </el-table-column>
        <el-table-column align="center" prop="" label="仓储费结算">
        </el-table-column>
        <el-table-column align="center" prop="" label="酒的结算">
        </el-table-column>
        <el-table-column align="center" prop="operation" label="操作">
          <template slot-scope="scope">
            <span class="view-btn" @click="$router.push({path:'/transferDetail',query:{id:scope.row.id}})">查看</span>
            <span class="recharge-btn" @click="$router.push({path:'/fundsTransfer'})">充值</span>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination v-show='page.total>page.pageSize' background layout="total,prev, pager, next,jumper" :page-size="page.pageSize" :total="page.total" :current-page="page.current" @current-change="handleCurrentChange">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      queryData: {
        date: '',
      },
      tableData: [{}],
      page: {
        pageSize: 10,
        current: 1,
        total: 0
      }
    };
  },
  methods: {
    async getTableData() {
      let { data } = await this.$post({
        api: '',
        data: {}
      });
      if (data.code === 0) {
        this.tableData = data.data;
      } else {
        this.$message({
          type: 'error',
          message: data.msg
        });
      }
    },
    handleCurrentChange(val) {
      this.page.current = val;
      this.getTableData();
    },
    exportData() {
      this.$confirm('确认进行导出操作吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$post({
          api: ""
        }).then(({ data }) => {
          if (data.code === 0) {
            let link = document.createElement('a');
            link.href = url + data.data.replace('static/', '');
            link.target = '_blank';
            link.download='timeout-order';
            link.click();
          } else {
            this.$message({
              type: 'error',
              message: data.msg
            });
          }
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        });
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.query {
  overflow: hidden;
  padding: 15px 30px;
  border-bottom: 1px solid #eeeeee;
  &-option {
    float: left;
    margin-right: 40px;
    &:last-child {
      margin-right: 0;
    }
  }
  .el-input {
    width: 250px;
  }
  .el-select{
    width:120px;
  }
}
.wrapper {
  padding: 0 15px;
  .view-btn {
    color: #0033ff;
    margin: 0 5px;
    cursor: pointer;
  }
  .recharge-btn{
    color: red;
    margin: 0 5px;
    cursor: pointer;
  }
}
</style>
